<template>
  <my-scrollbar ref="scrollRef" class="my-scrollbar">
    <div id="lyric">
      <div
        v-for="(item, index) in lyric"
        :key="index">
        {{ item.lyric }}
      </div>
    </div>
  </my-scrollbar>
</template>

<script>
import MyScrollbar from 'components/content/perfectscrollbar/MyScrollbar.vue'

export default {
  name: 'Lyric',
  components: {
    MyScrollbar
  },
  props: {
    lyric: {
      type: Array,
      default () {
        return []
      }
    }
  },
  computed: {
    isShowSongDetail () {
      return this.$store.state.isShowSongDetail
    }
  },
  watch: {
    isShowSongDetail () {
      if (!this.isShowSongDetail) return false
      // 1. 移除滚动到页面底部事件总线
      this.$bus.$off('yEnd')
      // 2. 刷新滚动条
      setTimeout(() => {
        this.$refs.scrollRef.update()
      }, 500)
    }
  }
}
</script>

<style scoped lang="less">
.my-scrollbar {
  width: 90%;
  padding-right: 30px;
  margin-top: 30px;
  flex: 1;
  #lyric {
    color: #2c2b2b;
    // overflow: hidden;
    > div {
      line-height: 30px;
      padding: 10px 0;
    }
  }
}
</style>
